<template>
	<div class="video">
    rrrrr
		<a-button @click="handleChange">切换</a-button>
		<video id="video" autoplay width="400" height="400" style="border:1px solid #ccc"></video>
	</div>
</template>
<script>
import "../../../../public/adapter.min.js";
import "../../../../public/webrtcstreamer.js";
export default {
name: 'index1',
data() {
	return {
		webRtcServer: null
	}
},
mounted() {
	//video：需要绑定的video控件ID
	//127.0.0.1:8000：启动webrtc-streamer的设备IP和端口，默认8000
	this.webRtcServer = new WebRtcStreamer('video', location.protocol + '//192.168.0.5:8000')
	//需要查看的rtsp地址
	this.webRtcServer.connect('rtsp://admin:Xbt@12131516@192.168.0.241:554/Streaming/Channels/102')
	//rtsp://user:password@ip:port/h264/ch1/main/av_stream--海康
	//rtsp://user:password@ip:port/cam/realmonitor?channel=1&subtype=0--大华
},
beforeDestroy() {
	this.webRtcServer.disconnect()
	this.webRtcServer = null
},
methods: {
	handleChange() {
		this.webRtcServer.connect('rtsp://admin:Xbt@12131516@192.168.0.241:554/Streaming/Channels/202')
	}
}
}
</script>
<style scoped>
.video {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url(../../../assets/images/back.png) no-repeat;
  background-size: 100% 100%;}</style>